<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <button id="lyf">刘亦菲</button>
    <button id="yr">颖儿</button>
    <img src="" alt="" title="">
    <!-- 需求 点击谁就弹出谁的照片 -->
    <script>
        // 1.获取事件源（元素） 谁要执行程序
     var lyf = document.getElementById('lyf')
     var yr = document.getElementById('yr')
     var img = document.querySelector('img')
    //  2.绑定事件 执行程序
    yr.onclick = function() {
        img.src = "image/2y.jpeg"
        img.title ='颖儿也是我女朋友'
    }
    lyf.onclick = function () {
        img.src = 'image/1l.webp'
        img.title = '刘亦菲是女朋友'
    }
    </script>
</body>

</html>